#ifndef CHARTUI_H
#define CHARTUI_H

#include <QObject>
#include <QWidget>
#include <QtCharts/QChartView>
#include <QtCharts/QStackedBarSeries>
#include <QtCharts/QBarSeries>
#include <QtCharts/QBarSet>
#include <QtCharts/QLineSeries>
#include <QtCharts/QSplineSeries>
#include <QTableWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QLabel>
#include <QList>
#include <QComboBox>
#include <QButtonGroup>
#include <QGroupBox>
#include <QValueAxis>
#include <QElapsedTimer>
#include "Icobutton.h"
#include "WifiUI.h"
#include "callout.h"

QT_CHARTS_BEGIN_NAMESPACE
class QChartView;
class QChart;
QT_CHARTS_END_NAMESPACE
QT_CHARTS_USE_NAMESPACE
class ChartUI : public QWidget
{
    Q_OBJECT
public:
    explicit ChartUI(QWidget *parent = 0);
protected:
    bool eventFilter(QObject *watched, QEvent *event);
private:
    QChart*         CreateLineChart();
    QTableWidget*   CreateTableWidget();
    QWidget         *CreateHanldWidget();
    void            AddChartPoint(qreal x, qreal y);
    void            TestStartCmd(char mode);
private:
    Callout             *m_callOut;
    WifiUI               *m_WifiUI;
    QTableWidget        *m_tableWidget;
    QFrame              *m_line;
    QLabel              *m_labelPower;
    QLabel              *m_labelTime;
    QLineEdit           *m_powerValue ;
    QLineEdit           *m_timeValue;
    QLabel              *m_measureUnit;
    QComboBox           *m_comboUnit;
    QLabel              *m_speedValue;
    QLabel              *m_speedunit;
    QLabel              *m_labelSpeed;
    QLabel              *m_labelReal;
    QLabel              *m_labelMax;
    QLabel              *m_Maxpullunit;
    QLabel              *m_Curpullunit;
    IcoButton           *m_WifiBtn;
    QPushButton         *m_testBtn;
    QPushButton         *m_uploadBtn;
    QLineEdit           *m_realValue ;
    QLineEdit           *m_maxValue;
    uchar               m_modeIndex;
    bool                m_runStart;
    bool                m_timeStart;
    QValueAxis          *m_pXaxis;
    QValueAxis          *m_pYaxis;
    QChart              *m_pchart;
    QLineSeries         *m_plinseries;
    QVector<double>     m_pullDatas;
    double              m_dTime;
    QElapsedTimer       m_xValue;
    float               m_fmaxValue;
    int                 m_iLanguageType;
    QRadioButton        *m_rBtnHis;
    QRadioButton        *m_rBtnCur;
    QButtonGroup        *m_bgGroup;
    QButtonGroup        *m_bgGroupMode;
    QGroupBox           *m_gbMode;
    QRadioButton        *m_rBtnRetention;
    QRadioButton        *m_rBtnPull;
    QComboBox           *m_csvCombo;
    QPushButton         *m_nextBtn;
    QPushButton         *m_prevBtn;
    QVector<float>      m_PullVec;
    QLabel              *m_labelPageNum;
    int                 m_curPage;
    QList<float>        m_writeDatas;
    QString             m_DataUpLoad;
    int                 m_CurUnit;
    QVector< QVector<char>>    m_DataVec;
    QMap<QString,QVector<QVector<char>>> m_csvData;
signals:
    void            SwitchLanguages(int);
    void            SendPullValue(const int);
    void            CalibrateValue(float,int);
    void            CallKeyBoard(const QString&,int);
    void            SendWifiUIKeyBoardData(const QString &objName, const QString &Data);
    void            WriteCsvSig();
public slots:
    void            ReceiveKeyBoardData(const QString &objName, const QString &Data);
    void            InsertData(QVector<QString> vec,QString );
    void            ChangeSpeedValue(const QString&);
    void            StartTest();
    void            UpLoadData();
    float           ShowPullValue(const float);
    void            LoadPullDatas();
    void            ReadDatas(QByteArray buff);
    void            ChangeLanguage(int);
    void            PushBtnGroupToggled(int);
    void            RadioBtnGroupToggled(int, bool);
    void            RadioBtnGroupModeToggled(int id, bool status);
    void            DistributeCsvData(const QString &name);
    void            NextPage();
    void            PrevPage();
    void            WriteCsv();
    void            LogoWifi();
    void            SwitchWifiStatus(bool);
    void            ChangeUnitIndex(int);
private:
    void            LoadHistoryDatas();

};

#endif // CHARTUI_H
